#ifndef __PARAMETER_H__
#define __PARAMETER_H__

#include <stdint.h>
#include <stddef.h>
#include "prjinfo.h"

#define POWER_ON_COUNT VirtAddVarTab[0]
// #define FACTORY_CRC VirtAddVarTab[1]
// #define APPLDATA_CRC VirtAddVarTab[2]
#define DOWNDATA_CRC VirtAddVarTab[3]
#define APPL_ADDR_LWORD VirtAddVarTab[4]
#define APPL_ADDR_HWORD VirtAddVarTab[5]
#define DOWNBYTELEN_LWORD VirtAddVarTab[6]
#define DOWNBYTELEN_HWORD VirtAddVarTab[7]
#define DOWN_ADDR_LWORD VirtAddVarTab[8]
#define DOWN_ADDR_HWORD VirtAddVarTab[9]
#define PARAINITFLAG VirtAddVarTab[NB_OF_VAR - 1]

typedef void (*pFunction)(void);
typedef struct
{
    uint32_t JumpAddress;
    pFunction JumpToApplication;
    uint32_t ApplicationAddress;
    uint32_t DownloadAddress;
    project_info_t *bootinfo;
    project_info_t *appinfo;
    project_info_t *downinfo;
    uint32_t downByteLen;
    uint16_t PowerOnCount;
    uint16_t FactoryCRC;
    uint16_t applCRC;
    uint16_t downCRC;
    uint16_t ParaInitFlag;
} bootloader_t;

extern bootloader_t btdata;

int32_t ParameterRead32(uint16_t VirtAddress, uint32_t *Data);
int32_t ParameterWrite32(uint16_t VirtAddress, uint32_t Data);
int32_t ParameterInit(void);


#endif // #ifndef __PARAMETER_H__
